import Cookies from 'js-cookie'
const TokenKey = 'x-access-token'

/**
 * 从cookies中获取token
 * @returns {*}
 */
export function getToken() {
    return Cookies.get(TokenKey)
}

/**
 * 保存token，存储到cookies
 * @param token
 * @returns {*}
 */
export function setToken(token) {
  let in120Minutes = new Date(new Date().getTime() + 120 * 60 * 1000);
  return Cookies.set(TokenKey, token, { expires: in120Minutes })
}

/**
 * 移除tokens
 * @returns {*}
 */
export function removeToken() {
    return Cookies.remove(TokenKey)
}
